[% setvar title Eliminate %]
<div id="archive-notice">
    <h3>This file is part of the Perl 6 Archive</h3>
    <p>To see what is currently happening visit <a href="http://www.perl6.org/">http://www.perl6.org/</a></p>
</div>
<div class='pod'>
<a name='TITLE'></a><h1>TITLE</h1>
<p>Eliminate =~ operator.</p>
<a name='VERSION'></a><h1>VERSION</h1>
<pre>  Maintainer: Steve Fink &lt;<a href='mailto:steve@fink.com'>steve@fink.com</a>&gt;
  Date: 21 Aug 2000
  Last Modified: 8 Sep 2000
  Mailing List: <a href='mailto:perl6-language-regex@perl.org'>perl6-language-regex@perl.org</a>
  Number: 138
  Version: 2
  Status: Withdrawn</pre>
<a name='ABSTRACT'></a><h1>ABSTRACT</h1>
<p>Replace EXPR =~ m/.../ with m/.../ EXPR, and similarly for s/// and
tr///. Force an explicit dereference when using qr/.../. Disallow the
implicit treatment of a string as a regular expression to match
against.</p>
<a name='CHANGES'></a><h1>CHANGES</h1>
<p>Withdrawn on 8 Sep 2000. Seems like discussion is pretty much over,
Larry's seen it and commented, and RFC164 mostly encompasses the idea,
so I'm withdrawing this one just to clean things up. Besides, I don't
want to maintain too many RFCs and I've got an idea for another one.
:-)</p>
<a name='DESCRIPTION'></a><h1>DESCRIPTION</h1>
<p>The EXPR =~ m/.../ syntax is ugly and unintuitive, something only its
mother (awk? sed?) could love. It performs a function that is
semantically no different from other forms of argument passing. This
RFC proposes to eliminate the =~ binding operator and treat m,
tr, and s almost like regular subroutine names but with slightly
different syntax and semantics.</p>
<p>To illustrate the proposal by example, the current</p>
<pre> /pattern/;
 m/pattern/;
 $x =~ /pattern/;
 ($a, $b, $c) = $x =~ /p(a)t(t)e(r)n/;
 gsx =~ s/pattern/subst/gsx;
 $r = qr/pattern/; $x =~ $r;
 $r = &quot;pattern&quot;; $x =~ $r;</pre>
<p>would become</p>
<pre> /pattern/;
 m/pattern/;
 /pattern/ $x; OR /pattern/ ($x);
 ($a, $b, $c) = /p(a)t(t)e(r)n/ $x;
 s/pattern/subst/gsx (gsx);
 $r = qr/pattern/; $r-&gt;($x);
 same as the previous, or $r = &quot;pattern&quot;; /$r/ ($x);</pre>
<p>Specifically, all patterns behave as if they are subroutines with a
($) prototype, except they have the current syntax for their first
argument, and $1 etc. interpolation remain unchanged.</p>
<p>qr/.../ would produces a CODE ref that may be invoked with the pattern
to match against. It would be a regular CODE ref rather than the
current magical Regexp reference type.</p>
<a name='RELATED WACKY IDEA #1: Everything's a reference'></a><h2>RELATED WACKY IDEA #1: Everything's a reference</h2>
<p>Alternatively, we could think of m/.../ as always returning a
reference, so that the syntax is /pattern/-&gt;($x). This is much more
visually distinctive, but runs afoul of Larry's &quot;no implicit
dereferencing&quot; rule in order to make /pattern/ default to
/pattern/-&gt;($_). On the other hand, $a =~ $b already breaks that rule
by dereferencing qr// refs, so maybe it's not such a big deal.</p>
<a name='RELATED WACKY IDEA #2: Creating references to matching operations'></a><h2>RELATED WACKY IDEA #2: Creating references to matching operations</h2>
<p>Now forget about the previous alternative and assume as in the main
section that we have /pattern/ ($x) and qr/pattern/-&gt;($x). This
naturally leads to \m/pattern/ or \&amp;m/pattern/ as an equivalent for
qr/pattern/, and also introduces \s/pattern/subst/ and
\tr/pattern/subst/ as new reference types.</p>
<a name='IMPLEMENTATION'></a><h1>IMPLEMENTATION</h1>
<p>Minor parser changes. Currently, the relevant rule in perly.y is
<b><code>term MATCHOP term</code></b>. The terms would be reversed, and the first
would
need to be renamed to cover only s///, m//, and tr/// (and
equivalents). So it would be something like <b><code>matchterm term</code></b>.</p>
<a name='REFERENCES'></a><h1>REFERENCES</h1>
<a name='Contributors'></a><h2>Contributors</h2>
<pre>  Dirk Meyers &lt;<a href='mailto:demyers@pscnet.com'>demyers@pscnet.com</a>&gt; came up with this idea.</pre>
</div>
